Programs executed by a processor often use memory regions known as stacks to store data temporarily. For example, a function call from a software routine may store (push) a return address onto a stack until the function is executed and then load (pop) the return address off of the stack in order to return to the routine and continue processing in program order.
Stacks are also used to store data to perform certain functions. For example, an addition of three numbers may push the sum of two of the numbers on the stack and then pop the result from the stack in order to add the sum to the third number.
In some stack architectures, a memory space, such as a register, is used to store the address of the next available space in a stack, the address of the last data that was pushed onto the stack, or the next data that is available on the stack to be popped from the stack. The address is often referred to as a stack pointer, because it, in effect, “points” to a location in a stack.
The stack pointer is updated whenever data is pushed onto or popped from the stack such that it points to the next appropriate location in the stack. In some prior art techniques, the stack pointer is updated by performing an addition or subtraction operation on the stack pointer value, depending upon whether a push or pop operation has taken place, respectively. Addition and subtraction operations may be performed in a microprocessor architecture by sending an addition or subtraction uop to an execution unit where the uop is executed and the stack pointer is updated with the result. Therefore, in some prior art microprocessor architectures, a pop or push instruction may require at least two uops to be executed; one for the load or store operation and one for the stack pointer value subtraction or addition operation.
Other stack instructions may also access the stack, but performing a uop to update the stack pointer requires using processor resources and time that could be used processing other operations. Furthermore, performing at least two uops to perform a single pop or push instruction inhibits processor performance and increases power consumption.